package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.gdms.service.CourseAdjustSrevice;
import com.zr.gdms.serviceimpl.CourseAdjustSreviceimpl;

import net.sf.json.JSONObject;

public class CourseAdjustController extends HttpServlet {
	CourseAdjustSrevice cs=new CourseAdjustSreviceimpl();
	/**
	 * 修改课题状态
	 * */		
	@Override
			protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
				// TODO Auto-generated method stub
				doPost(req, resp);
			}
			@Override
			protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			// TODO Auto-generated method stub
				resp.setCharacterEncoding("utf8");
				HttpSession session =req.getSession();
				int cid=Integer.parseInt(req.getParameter("cid"));
				String cstate=req.getParameter("cstate");
				PrintWriter pt=resp.getWriter();
				boolean  flag= cs.NoCourseAdjust(cid, cstate);
				if(flag){					
					JSONObject result=new JSONObject(); 
					  result.put("success", "true");
					  result.put("errorMsg", "修改成功"); 		 
					  pt.write(result.toString());
					  resp.sendRedirect("student.jsp");
				}else{
					session.setAttribute("Msg", "失败");
					resp.sendRedirect("student");
				}		
		
			}
}
